import { Application } from 'egg';

export default (app: Application) => {
  const { controller, router } = app;

  router.prefix('/api');
  router.get('/', controller.home.index);

  router.post('/users/create', controller.user.createByEmail);
  router.get('/users/current', controller.user.show);
  router.post('/users/login', controller.user.loginByEmail);
  router.post('/users/genVeriCode', controller.user.sendVerifyCode);
  router.post('/users/loginByCellphone', controller.user.loginByCellphone);
  router.patch('/users/:id', controller.user.update);
  router.delete('/users/:id', controller.user.delete);
  router.get('/users/:id', controller.user.getUserInfo);

  router.post('/works', controller.work.createWork);
  router.post('/works/copy/:id', controller.work.copyWork);
  router.get('/works', controller.work.myList);
  router.get('/templates', controller.work.templateList);
  router.patch('/works/:id', controller.work.update);
  router.delete('/works/:id', controller.work.delete);
  router.post('/works/publish/:id', controller.work.publishWork);
  router.post('/works/publish-template/:id', controller.work.publishTemplate);
  router.get('/works/:id', controller.work.getWork);

  router.post('/utils/upload', controller.utils.fileUploadByStream);
  router.get('/utils/pages/:idAndUuid', controller.home.renderH5Page);
};
